Is it fair to punish the whole class?

Is it fair to punish the whole class?